<?php

namespace App\Observers;

use App\Models\User;
use Illuminate\Support\Facades\DB;

class UserObserver {
    public function saving(User $user){
        if(empty($user->avatar)){
            $user->avatar = url('fakers/avatars/face16.jpg');
        }
    }
//   public function deleted(User $user){
//       DB::table('replies')->where('user_id',$user->id)->delete();
//       //获取该用户发的帖子
//       $topics = DB::table('topics')->where('user_id',$user->id)->get();
//       foreach ($topics as $topic){
//           DB::table('replies')->where('topic_id',$topic->id)->delete();
//       }
//       DB::table('topics')->where('user_id',$user->id)->delete();
//   }
}
